﻿using System;
using System.Collections.Generic;
using System.Web.Routing;

using Nop.Core.Plugins;
using Nop.Services.Configuration;
using Nop.Services.Localization;

namespace RonsHouse.Plugin.Misc.AlternativeStorage
{
	public class AlternativeStoragePlugin : BasePlugin
	{
		private readonly ISettingService _settingService;

		public AlternativeStoragePlugin(ISettingService settingService)
		{
			this._settingService = settingService;
		}

		public override void Install()
		{
			//this.AddOrUpdatePluginLocaleResource("Plugins.Misc.WebServices.Description1", "Actually configuration is not required. Just some notes:");
			
			var settings = new AlternativeStorageSettings
			{
				StorageProvider = "RonsHouse.Plugin.Misc.AlternativeStorage.FileSystemStorageProvider, RonsHouse.Plugin.Misc.AlternativeStorage",
				FileSystemPicturePath = "~/Pictures",
				FileSystemDownloadPath = "~/Downloads"
			};
			_settingService.SaveSetting(settings);

			base.Install();
		}

		public override void Uninstall()
		{
			//this.DeletePluginLocaleResource("Plugins.Misc.WebServices.Description1");

			_settingService.DeleteSetting<AlternativeStorageSettings>();

			base.Uninstall();
		}

		/// <summary>
		/// Gets a route for provider configuration
		/// </summary>
		/// <param name="actionName">Action name</param>
		/// <param name="controllerName">Controller name</param>
		/// <param name="routeValues">Route values</param>
		public void GetConfigurationRoute(out string actionName, out string controllerName, out RouteValueDictionary routeValues)
		{
			actionName = "Configure";
			controllerName = "AlternativeStorage";
			routeValues = new RouteValueDictionary() { { "Namespaces", "RonsHouse.Plugin.Misc.AlternativeStorage.Controllers" }, { "area", null } };
		}
	}
}